﻿using System;
using System.Windows.Forms;

namespace IoTClient.WinformExt.FormS
{
    public partial class ChangeVarableValue : Form
    {
        public ChangeVarableValue()
        {
            InitializeComponent();
        }

        private string address;

        public ChangeVarableValue(string add)
        {
            InitializeComponent();
            address = add;
        }

        private void button1_Click(object sender, EventArgs e)
        {
            object var = null;
            switch (IoTClient.Auto.AllDeviceList.SocketDeviceList[2].AllVarableDictionary[address].DataType)
            {
                case IoTClient.Enums.DataTypeEnum.None:
                    break;

                case IoTClient.Enums.DataTypeEnum.Bool:
                    break;

                case IoTClient.Enums.DataTypeEnum.Byte:
                    var = Convert.ToByte(textBox4.Text);
                    break;

                case IoTClient.Enums.DataTypeEnum.Int16:
                    break;

                case IoTClient.Enums.DataTypeEnum.UInt16:
                    break;

                case IoTClient.Enums.DataTypeEnum.Int32:
                    var = Convert.ToInt32(textBox4.Text);

                    break;

                case IoTClient.Enums.DataTypeEnum.UInt32:
                    break;

                case IoTClient.Enums.DataTypeEnum.Int64:
                    break;

                case IoTClient.Enums.DataTypeEnum.UInt64:
                    break;

                case IoTClient.Enums.DataTypeEnum.Float:
                    break;

                case IoTClient.Enums.DataTypeEnum.Double:
                    break;

                default:
                    break;
            }
            var addr = IoTClient.Auto.AllDeviceList.SocketDeviceList[2].AllVarableDictionary[address].Address;
            IoTClient.Auto.AllDeviceList.SocketDeviceList[2][addr] = var;
            this.Close();
        }
    }
}